package org.springboot3.project.demoapi.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson2.JSON;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springboot3.project.demoapi.DemoService;
import org.springboot3.project.demoapi.input.AbilityApiJsonInputDTO;
import org.springboot3.project.demoapi.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * todo
 *
 * @author weiwei
 * @since 2024/6/11 11:38
 */
@RestController
public class TestController {

    @DubboReference(interfaceClass = DemoService.class, version = "1.0", check = false)
    private DemoService demoService;

    @GetMapping("/sayHello")
    public String sayHello(String name) {
        return demoService.sayHello(name);
    }

    @GetMapping("/testMap")
    public String testMap() {
        AbilityApiJsonInputDTO apiJsonInputDTO = new AbilityApiJsonInputDTO();
        apiJsonInputDTO.setDsCode("sadgas");
        apiJsonInputDTO.setSql("sgdasgdasgas");
        HashMap<String,String> map = new HashMap<>();
        map.put("key","asdasd");
        map.put("dasd","dasd");
        apiJsonInputDTO.setTableKeyMap(map);
        apiJsonInputDTO.setVersion("1.0");

        List<Map<String, Object>> maps = demoService.testListMap(apiJsonInputDTO);
        return JSON.toJSONString(maps);
    }

    @Autowired
    private TestService testService;

    @GetMapping("/lock4jTest")
    public String lock4jTest(String key){
        String s = testService.lock4jTest(key);
        return s;
    }

}
